<?php 
	include($_SERVER['DOCUMENT_ROOT']."/headerins.php");
?>

<?php

	$return = array();
	  $sql = '
			SELECT
				id, code, name, price1, ball
			FROM
				material
			WHERE code = '.$_GET['code']
	  ;
	  $result = mysql_query($sql);

		if (!$result) {
			echo 'Ошибка запроса: ' . mysql_error();
			$return['result']="error";//'Ошибка запроса: ' . mysql_error();	
			exit;
		}
	
	  while($row = mysql_fetch_array($result)){
		$return['result'] = "ok";
		$return['ID'] = $row['id'];
		$return['Code'] = $row['code'];
		$return['MatName'] = $row['name'];
		$return['Price1'] = $row['price1'];
		$return['Ball'] = $row['ball'];
	  }
	
	print json_encode($return);

?>
